package com.hundsun.network.uc.common;

import javax.servlet.http.HttpServletRequest;
import java.net.UnknownHostException;

/**
 * Created by zhengkk19738 on 2018/5/2.
 */
public class ServerUtil {
    /**
     * 获取本机的服务器地址(以客户端访问的ip为主)
     *
     * @return
     * @throws UnknownHostException
     * @Title:函数
     * @Description:Comment for non-overriding methods
     * @author 张颖辉
     * @date 2018年3月5日上午11:13:37
     */
    public static String getServerUrl(HttpServletRequest request) throws UnknownHostException {
        String serverUrl = null;
        StringBuffer requestURL = request.getRequestURL();
        serverUrl = requestURL.substring(0, requestURL.lastIndexOf("/"));
        return serverUrl;
    }
}
